home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 2000 June: Reference Library / Dev.CD Jun 00 RL Disk 1.toast / pc / technical documentation / develop / develop issue 27 / develop issue 27 code / 3d game controls / source / traps.c < prev   
Encoding:
Text File  |  1996-06-29  |  1.4 KB  |  59 lines

  1. //--------------------------------------------------------------------------------------------
  2. //  Event Handling Code
  3. //
  4. //      by Philip McBride
  5. //        taken from code by Nick Thompson
  6. //
  7. //--------------------------------------------------------------------------------------------
  8.  
  9.  
  10. #include <Types.h>
  11. #include <Traps.h>
  12. #include <OSUtils.h>
  13. #include <GestaltEqu.h>
  14.  
  15. short myNumToolboxTraps(void);
  16. TrapType myGetTrapType(short theTrap);
  17. Boolean    myTrapAvailable(short theTrap);
  18.  
  19. //--------------------------------------------------------------------------------------------
  20. //  Get Trap Num
  21. //
  22. short myNumToolboxTraps(void)
  23. {
  24.     if (NGetTrapAddress(_InitGraf, ToolTrap) == NGetTrapAddress(0xAA6E,ToolTrap))
  25.         return 0x0200;
  26.     else
  27.         return 0x0400;
  28. }
  29.  
  30. //--------------------------------------------------------------------------------------------
  31. //  Get Trap Type
  32. //
  33. TrapType myGetTrapType(short theTrap)
  34. {
  35.     if ((theTrap & 0x0800) > 0)
  36.         return ToolTrap;
  37.     else
  38.         return OSTrap;
  39. }
  40.  
  41. //--------------------------------------------------------------------------------------------
  42. //  Check if Trap Available
  43. //
  44. Boolean    myTrapAvailable(short theTrap)
  45. {
  46.     TrapType tType;
  47.     Boolean isAvail;
  48.     
  49.     tType = myGetTrapType(theTrap);
  50.     if (tType == ToolTrap)
  51.         {
  52.             theTrap &= 0x07FF;
  53.             if (theTrap >= myNumToolboxTraps())
  54.                 theTrap = _Unimplemented;
  55.         }
  56.     
  57.     isAvail = NGetTrapAddress(theTrap, tType) != NGetTrapAddress(_Unimplemented, ToolTrap);
  58.     return isAvail;
  59. }